function GAD_Etom_Events_vs_Speed_CDFs(Mobility_and_ER_Data_Summary)
%% Compute fraction of event that happens during certain animal's speed CDFs for p-WT first
WT_Speed = [];
for n = 1:size(Mobility_and_ER_Data_Summary,2)
    if isempty(WT_Speed) && strcmp(Mobility_and_ER_Data_Summary(n).genotype, 'a5-i-WT')
        WT_Speed = Mobility_and_ER_Data_Summary(n).Session2_Speed_During_Event;
    elseif ~isempty(WT_Speed) && strcmp(Mobility_and_ER_Data_Summary(n).genotype, 'a5-i-WT')
        WT_Speed = cat(1, WT_Speed, Mobility_and_ER_Data_Summary(n).Session2_Speed_During_Event);
    end
end

[WT_Speed_F, WT_Speed_X, ~, ~] = ecdf(WT_Speed,'Function','cdf','Alpha',0.05);
WT_Speed_X = cat(1, 0, WT_Speed_X, 50);
WT_Speed_F = cat(1, 0, WT_Speed_F, 1);

%% Compute for a5-i-KO
KO_Speed = [];
for n = 1:size(Mobility_and_ER_Data_Summary,2)
    if isempty(KO_Speed) && strcmp(Mobility_and_ER_Data_Summary(n).genotype, 'a5-i-KO')
        KO_Speed = Mobility_and_ER_Data_Summary(n).Session2_Speed_During_Event;
    elseif ~isempty(KO_Speed) && strcmp(Mobility_and_ER_Data_Summary(n).genotype, 'a5-i-KO')
        KO_Speed = cat(1, KO_Speed, Mobility_and_ER_Data_Summary(n).Session2_Speed_During_Event);
    end
end

[KO_Speed_F, KO_Speed_X, ~, ~] = ecdf(KO_Speed,'Function','cdf','Alpha',0.05);
KO_Speed_X = cat(1, 0, KO_Speed_X, 50);
KO_Speed_F = cat(1, 0, KO_Speed_F, 1);

%% plot graphs
figure
plot(WT_Speed_X, WT_Speed_F, 'r', 'LineWidth', 3);
hold on
plot(KO_Speed_X, KO_Speed_F, 'b', 'LineWidth', 3);
xlim([0,25]);
xlabel('Speed during Event (cm/sec)')
ylabel('Cumulative Fraction of Events')
legend('p-WT', '\alpha5-i-KO', 'Location','southeast')
set(gca, 'FontSize', 20)
hold off

end
